﻿namespace Jim.OA.Service;

/// <summary>
/// 操作流程
/// </summary>                                   
[ApiDescriptionSettings(ApplicationConst.GroupName)]
public  class OAWorkflowOperService : IDynamicApiController, ITransient
{
    private readonly OAClientFactory _oaClientFactory;

    public OAWorkflowOperService(OAClientFactory oaClientFactory)
    {
        _oaClientFactory = oaClientFactory;
    }

    /// <summary>
    /// 创建新流程
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [NonUnify]
    public async Task<OADoCreateRequestOutput> New(OADoCreateRequestInput input)
    {
        var client = _oaClientFactory.CreateRestClient();
        client.IsDebug = true;
        var result = await client.Execute(input);
        return result;
    }

    /// <summary>
    /// 流程提交
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [NonUnify]
    [ApiDescriptionSettings(KeepName = true)]
    public async Task<SdkResponse> Submit(OASubmitRequestInput input)
    {
        var client = _oaClientFactory.CreateRestClient();
        client.IsDebug = true;
        var result = await client.Execute(input);
        return result;
    }

    /// <summary>
    /// 流程退回
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [NonUnify]
    public async Task<SdkResponse> Reject(OARejectRequestInput input)
    {
        var client = _oaClientFactory.CreateRestClient();
        client.IsDebug = true;
        var result = await client.Execute(input);
        return result;
    }

    /// <summary>
    /// 转发、意见征询、转办
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [NonUnify]
    public async Task<SdkResponse> Forward(OAForwardRequestInput input)
    {
        var client = _oaClientFactory.CreateRestClient();
        client.IsDebug = true;
        var result = await client.Execute(input);
        return result;
    }

    /// <summary>
    /// 流程当前操作人可以保存意见
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [NonUnify]
    public async Task<SdkResponse> SaveLog(OASaveLogRequestInput input)
    {
        var client = _oaClientFactory.CreateRestClient();
        client.IsDebug = true;
        var result = await client.Execute(input);
        return result;
    }

    /// <summary>
    /// 流程干预
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [NonUnify]
    public async Task<SdkResponse> Intervenor(OADoIntervenorRequestInput input)
    {
        var client = _oaClientFactory.CreateRestClient();
        client.IsDebug = true;
        var result = await client.Execute(input);
        return result;
    }

    /// <summary>
    /// 删除流程
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [NonUnify,HttpPost]
    [ApiDescriptionSettings(KeepName = true)]
    public async Task<SdkResponse> Delete(OADeleteRequestInput input)
    {
        var client = _oaClientFactory.CreateRestClient();
        client.IsDebug = true;
        var result = await client.Execute(input);
        return result;
    }

    /// <summary>
    /// 强制收回
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [NonUnify]
    public async Task<SdkResponse> ForceDrawBack(OAForceBackRequestInput input)
    {
        var client = _oaClientFactory.CreateRestClient();
        client.IsDebug = true;
        var result = await client.Execute(input);
        return result;
    }

    /// <summary>
    /// 强制归档
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [NonUnify]
    public async Task<SdkResponse> ForceOver(OAForceOverRequestInput input)
    {
        var client = _oaClientFactory.CreateRestClient();
        client.IsDebug = true;
        var result = await client.Execute(input);
        return result;
    }
}
